home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / KMAGV1.ZIP / MEXAMPLE.PAS < prev    next >
Pascal/Delphi Source File  |  1995-09-13  |  2KB  |  80 lines

  1. {MEXAMPLE.PAS / EXAMPLE FOR THE MOUSE}
  2. {WRITING BY THE KING IN 10/13/95     }
  3.  
  4. Uses Crt;         {USING CRT FOR THE EXAMPLE}
  5. Type
  6.     {This is the For the buttons}
  7.     ButtonType = (None,Left,Right,LeftRight);
  8. {MouseType is the type for all the details we need for it}
  9. {X,Y Are the positions of the mouse}
  10. {Buttons is the buttons that pressed}
  11. {1 = LEFT BUTTON}
  12. {2 = RIGHT BUTTON}
  13. {3 = LEFT AND RIGHT BUTTONS}
  14.  
  15.     MouseType = Record
  16.         X,Y:Word;
  17.         Buttons : ButtonType;
  18.     End;
  19.  
  20. Var
  21.     Mouse:MouseType;
  22.     Button : String;
  23.  
  24. {This function get us the status of the mouse}
  25. Procedure GetMouse(Var Mouse:MouseType);Assembler;
  26.     Asm
  27.         Push Ds                 {Saving DS}
  28.         Mov Ax,0003h            {Function 0003H INT 33H GET STATUS}
  29.         Int 33h
  30.         Lds Si,Mouse            {[DS:SI] = MOUSE}
  31.         Shr CX,3                {FOR DIVIDE IT WITH 8}
  32.         Shr DX,3
  33.         Mov [Ds:Si],CX          {[DS:SI] = X = CX}
  34.         Mov [Ds:Si+2],DX        {[DS:SI+2] = Y = DX}
  35.         Mov [DS:Si+4],BX        {[DS:SI+4] = BUTTON = BX}
  36.         Pop Ds                  {Restoring DS}
  37.     End;
  38.  
  39. {Thus function Reseting the mouse and return true if the mouse is installed}
  40. Function ResetMouse:Boolean;Assembler;
  41. Asm
  42.     Mov Ax,0000h
  43.     Int 33h
  44. End;
  45.  
  46. {Show the mouse on the screen}
  47. Procedure ShowMouse;Assembler;
  48. Asm
  49.     Mov Ax,0001h
  50.     Int 33h
  51. End;
  52.  
  53. Procedure HideMouse;Assembler;
  54. Asm
  55.     Mov Ax,0002h
  56.     Int 33h
  57. End;
  58. Begin
  59. Clrscr;
  60. If Not ResetMouse Then
  61.     Writeln('Mouse Driver Not Installed !')
  62. Else
  63.     Writeln('Mouse Installed !');
  64.     Writeln('"ESC" To Exit..');
  65. ShowMouse;
  66. Repeat
  67.     GetMouse(Mouse);
  68.     GotoXy(1,3);
  69.     Writeln('X = ',Mouse.X , '  ');
  70.     Writeln('Y = ',Mouse.Y , '  ');
  71.     Case Mouse.Buttons Of
  72.     NONE : BUTTON := 'NONE';
  73.     LEFT : BUTTON := 'LEFT';
  74.     RIGHT: BUTTON := 'RIGHT';
  75.     LEFTRIGHT : BUTTON :='LEFT AND RIGHT';
  76.     End;
  77.     Writeln('BUTTONS = ',BUTTON+'              ');
  78. Until(Port[$60]=1);
  79. HideMouse;
  80. End.